<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<div id="test-div" contentEditable="true"><select></select></div>
<script>
description('Undo command should not make a selection anchored in another document.');

window.jsTestIsAsync = true;

var div = document.getElementById('test-div');
var selection = window.getSelection();

div.focus();
document.execCommand('SelectAll');
document.execCommand('Indent');
document.execCommand('Outdent');

var anotherDocument = document.implementation.createHTMLDocument('');
anotherDocument.body.appendChild(selection.getRangeAt(0).extractContents());

div.contentEditable = false;

document.execCommand('Undo');
document.execCommand('FindString', false, 'x');

window.setTimeout(function () {
    document.body.removeChild(div);
    testPassed('Did not crash.');
    finishJSTest();
}, 0);
</script>
</body>
</html>
